package com.song.demo.webmvc.aop;

import java.lang.reflect.Method;

/**
 * 前置通知具体实现
 */
public class GPBeforeAdvice extends GPAbstractAspectJAdvice implements GPAdvice,GPMethodInterceptor {

    private GPJoinPoint joinPoint;

    public GPBeforeAdvice(Method method, Object newInstance) {
        super(method,newInstance);
    }

    @Override
    public Object invoke(GPMethodInvocation mi) throws Throwable {
        this.joinPoint= mi;
        before(mi.getMethod(),mi.getArguments(),mi.getThis());
        return mi.proceed();
    }

    public void before(Method method,Object[] args,Object target) throws Throwable {
        invokeAdviceMethod(this.joinPoint,null,null);
    }

}
